﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data;

namespace CustomsSystem.BLL
{
    public class WorkflowHandleManage
    {
        private readonly CustomsSystem.DAL.WorkflowHandleService dal=new CustomsSystem.DAL.WorkflowHandleService();
        public WorkflowHandleManage(){}

		/// <summary>
		/// 增加一条数据
		/// </summary>
		public int Add(CustomsSystem.Model.workflow model)
		{
			return dal.Add(model);
		}

		/// <summary>
		/// 更新一条数据
		/// </summary>
		public bool Update(CustomsSystem.Model.workflow model)
		{
			return dal.Update(model);
		}

		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool Delete(int WKID)
		{
			
			return dal.Delete(WKID);
		}
		/// <summary>
		/// 删除一条数据
		/// </summary>
		public bool DeleteList(string WKIDlist )
		{
			return dal.DeleteList(WKIDlist );
		}

		/// <summary>
		/// 得到一个对象实体
		/// </summary>
		public CustomsSystem.Model.workflow GetModel(int WKID)
		{
			
			return dal.GetModel(WKID);
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetList(string strWhere)
		{
			return dal.GetList(strWhere);
		}

        /// <summary>
        /// 获取多表数据的视图
        /// </summary>
        /// <returns></returns>
        public DataSet GetView(string strWhere)
        {
            return dal.GetView(strWhere);
        }
        /// <summary>
        /// 获取员工统计的视图
        /// </summary>
        /// <returns></returns>
        public DataSet GetCountView(string strWhere)
        {
            return dal.GetCountView(strWhere);
        }
        
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<CustomsSystem.Model.workflow> GetModelList(string strWhere)
		{
			DataSet ds = dal.GetList(strWhere);
			return DataTableToList(ds.Tables[0]);
		}
		/// <summary>
		/// 获得数据列表
		/// </summary>
		public List<CustomsSystem.Model.workflow> DataTableToList(DataTable dt)
		{
			List<CustomsSystem.Model.workflow> modelList = new List<CustomsSystem.Model.workflow>();
			int rowsCount = dt.Rows.Count;
			if (rowsCount > 0)
			{
				CustomsSystem.Model.workflow model;
				for (int n = 0; n < rowsCount; n++)
				{
					model = dal.DataRowToModel(dt.Rows[n]);
					if (model != null)
					{
						modelList.Add(model);
				    }
				}
			}
			return modelList;
		}

		/// <summary>
		/// 获得数据列表
		/// </summary>
		public DataSet GetAllList()
		{
			return GetList("");
		}
        /// <summary>
        /// 判断是否超时
        /// </summary>
        /// <param name="sheedID"></param>
        /// <returns></returns>
        public int GetIntime(int sheedID , int type)
        {
            return dal.GetIntimeFlag(sheedID.ToString(),type);
        }
    }
}
